<script>
import {Toast} from "vant";

export default {
  name: "WWorkOrderGuaDanView",
  data() {
    return {
      list: {},
      guadan:""
    }
  },
  methods: {
    onBack() {
      this.$router.go(-1);
    },
    fanhui(){
      this.list.gdstatus = 2;
      this.list.gdyy = this.guadan;
      this.axios.post(`http://localhost:9999/api-work-order-service/work-order/save`, this.list).then(res => {
        if (res.data.code === 1) {
          Toast.success('挂单成功');
          this.$router.go(-1);
        } else {
          Toast.fail('挂单失败');
        }
      })
    }
  },
  created() {
    this.guadan = "";
    // 获取参数
    this.id = this.$route.query.id
    // 查询
    this.axios.get(`http://localhost:9999/api-work-order-service/work-order/findById?id=` + this.id).then(res => {
      this.list = res.data.data;
    })
  }
}
</script>

<template>
<div>
  <van-nav-bar
      title="挂单"
      left-arrow
      @click-left="onBack"
      fixed
  />
  <div>
    <h4>挂单原因</h4>
    <van-cell-group>
      <van-field v-model="guadan" label="" placeholder="请填写挂单原因..." />
    </van-cell-group>
  </div>
  <van-button type="info" size="large" @click="fanhui">确定</van-button>
</div>
</template>

<style scoped>

</style>